﻿(function () {

	var filteredLookupContext = {};

	// Init Templates object for View mode
	filteredLookupContext.Templates = {};
	filteredLookupContext.Templates.Fields = {
		"FilteredLookupField": { "View": filteredLookupViewTemplate } // pass rendering control to delegate function filteredLookupViewTemplate
	};
	// register rendering overriding
	SPClientTemplates.TemplateManager.RegisterTemplateOverrides(filteredLookupContext);
})();

function filteredLookupViewTemplate(ctx) {
	var lookup = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
	// read lookup value and returns as string
	if (lookup)
		return lookup[0].lookupValue;
	return "";
}